package com.xpf.service.status;

import com.xpf.service.status.entity.BpmProcessFailureEvent;
import com.xpf.service.status.entity.BpmProcessSuccessEvent;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class AbstractResultCallbackService implements IResultCallbackService {

    @Override
    public void resultCallbackSuccess(BpmProcessSuccessEvent event) {
        //流转之前
        statusEvolutionBefore(event);

        //回调状态流转
        doStatusEvolution(event);

        //流转之后
        statusEvolutionAfter(event);
    }

    protected abstract void doStatusEvolution(BpmProcessSuccessEvent event);

    private void statusEvolutionBefore(BpmProcessSuccessEvent event) {

    }

    private void statusEvolutionAfter(BpmProcessSuccessEvent event) {

    }

    @Override
    public void resultCallbackError(BpmProcessFailureEvent event) {
        log.error("BPM状态流转异常:{}", event);
    }
}
